home *** CD-ROM | disk | FTP | other *** search
/ Grand Slam / GrandSlam volume 1.iso / 030 / grasputl.arj / GLCOMP.ALL < prev    next >
Text File  |  1990-11-12  |  11KB  |  252 lines

  1. From zaphod.mps.ohio-state.edu!samsung!olivea!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!unido!rwthinf!cip-s03!berg Fri Nov  9 14:44:39 EST 1990
  2.  
  3. This is one of those quick, dirty and portable programs :-).
  4.  
  5. To give those people who want to create .gl files on their own or write
  6. an interpreter on a different machine than the pc a helping hand: here
  7. is a .gl file composer/decomposer.  It extracts the separate files which
  8. are in an .gl archive, or can create a new archive from the files you supply.
  9.  
  10. I have included the source and an executable (for the pc) in the posting.
  11. Both are provided as is, no warranties or support from my side can be
  12. expected.  Both are donated to the public domain.  So feel free to sell the
  13. program :-)
  14.  
  15. As I'm not supporting this program anymore, there really is no need to contact
  16. me (in case any problems arise, check with your local C guru :-).
  17. Should you however have an uncontrollable urge to write me some mail,
  18. then please use the mail address mentioned in the signature (*NOT* the address
  19. in the From: line).
  20. --
  21. Sincerely,                 berg%cip-s01.informatik.rwth-aachen.de@unido.bitnet
  22.            Stephen R. van den Berg.
  23. "I code it in 5 min, optimize it in 90 min, because it's so well optimized:
  24. it runs in only 5 min.  Actually, most of the time I optimize programs."
  25. --------------------- cut here ---------------------------------------
  26. /*
  27.    glcomp.c: a ".gl" file composer/decomposer.
  28.  
  29.    To compose a new ".gl" file, enter each file's name in a listfile.
  30.    Supply the listfile's name as the second argument.
  31.  
  32.    Originally programmed for TurboC.
  33.    Should be portable enough though.
  34.  
  35.    Donated to the public domain by S.R.van den Berg on 1990-11-08
  36.    (That means I will not support the code any further, and you can do
  37.    with the code whatever you want (except copyright it :-)).
  38.    Reachable on INTERNET as:
  39.                   berg%cip-s01.informatik.rwth-aachen.de@unido.bitnet
  40.    Reachable on BITNET as:
  41.                   berg%cip-s01.informatik.rwth-aachen.de@unido
  42. */
  43.  
  44. #pragma  option   -a- -r -O -Z -f-
  45. #include <io.h>
  46. #include <fcntl.h>
  47. #include <stdlib.h>
  48. #include <sys/stat.h>
  49. #define  S_IFILE  (S_IFREG|S_IREAD|S_IWRITE)
  50.  
  51. #define  BUFSIZ   8000U
  52. #define  MAXFILES 1024
  53.  
  54. #define  RECLEN   17
  55.  
  56. unsigned _stklen=1024,_heaplen=4U;
  57. typedef unsigned char uchar;
  58. struct {long offset;char name[13];} file[MAXFILES];
  59. uchar buffer[BUFSIZ];
  60. int in,out;
  61.  
  62. long fgetl(){unsigned i;
  63.  i=fgetw();return i|(long)(unsigned)fgetw()<<16;}
  64.  
  65. main(argc,argv)char*argv[];{int i;char *p;
  66.  if(argc<2||argc>3){
  67.    putse("Usage: glcomp xxx.gl [listfile]\n");return 1;}
  68.  if(0>(in=open(argv[argc-1],O_RDONLY|O_BINARY))){
  69. couldntfind:
  70.    putse("Couldn't find ");putse(argv[argc-1]);return 2;}
  71.  if(argc==2){
  72.    if(fgetw()/RECLEN>MAXFILES){
  73. toomanyfiles:
  74.       putse("Too many files\n");return 3;}
  75.    i=0;
  76.    do{
  77.       file[i].offset=fgetl();read(in,file[i].name,RECLEN-4);}
  78.    while(*file[i++].name);
  79.    i=0;
  80.    do{
  81.       if(0>
  82.          (out=open(p=file[i].name,O_WRONLY|O_BINARY|O_CREAT|O_TRUNC,S_IFILE))){
  83. couldntopen:
  84.          putse("Couldn't open ");putse(p);return 4;}
  85.       puts(p);puts("\n");lseek(in,SEEK_SET,file[i].offset);copyfw(fgetl());
  86.       close(out);}
  87.    while(*file[++i].name);}
  88.  else{long len;
  89.    for(i=0;;){
  90.       if(i>MAXFILES)
  91.          goto toomanyfiles;
  92.       p=file[i++].name;
  93.       do
  94.          if(eof(in))
  95.             goto nomorefiles;
  96.       while((*p=fgetc())<=' ');
  97.       while((*++p=fgetc())>' ');
  98.       *p='\0';}
  99. nomorefiles:
  100.    close(in);*p='\0';
  101.    if(0>(out=open(p=argv[1],O_WRONLY|O_BINARY|O_CREAT|O_TRUNC,S_IFILE)))
  102.       goto couldntopen;
  103.    fputw(i=i*RECLEN);write(out,file,i);
  104.    i=0;
  105.    puts("Reading:\n");
  106.    do{
  107.       if(0>(in=open(p=file[i].name,O_RDONLY|O_BINARY)))
  108.          goto couldntfind;
  109.       puts(p);puts("\n");file[i].offset=lseek(out,0L,SEEK_CUR);
  110.       fputl(len=lseek(in,0L,SEEK_END));lseek(in,0L,SEEK_SET);copyfw(len);
  111.       close(in);}
  112.    while(*file[++i].name);
  113.    lseek(out,2L,SEEK_SET);i=0;
  114.    do{
  115.       fputl(file[i].offset);write(out,file[i].name,RECLEN-4);}
  116.    while(*file[i++].name);}
  117.  return 0;}
  118.  
  119. fgetc(){uchar i;
  120.  read(in,&i,1);return i;}
  121.  
  122. fgetw(){int i;
  123.  i=fgetc();return i|fgetc()<<8;}
  124.  
  125. fputc(i){uchar j;
  126.  j=i;write(out,&j,1);}
  127.  
  128. fputw(i){
  129.  fputc(i);fputc(i>>8);}
  130.  
  131. fputl(i)long i;{
  132.  fputw(i);fputw(i>>16);}
  133.  
  134. copyfw(i)long i;{long j;
  135.  while(i>0L){j=i;
  136.    i-=
  137.    (unsigned)write(out,buffer,read(in,buffer,(unsigned)min(i,(long)BUFSIZ)));
  138.    if(i>=j){
  139.       putse("Choking...  Need space...\n");close(in);close(out);abort();}}}
  140.  
  141. #define STDOUT 1
  142. #define STDERR 2
  143. #include <io.h>
  144.  
  145. puts(a)char *a;{putsfd(a,STDOUT);}
  146.  
  147. putse(a)char *a;{putsfd(a,STDERR);}
  148.  
  149. putsfd(a,fd)register char *a;{register char *b;
  150.  b=a;
  151.  while(*a) a++;
  152.  write(fd,b,a-b);}
  153.  
  154. _setupio(){}   /* Only use this if NO streams are used */
  155.  
  156. -------------------------- cut here ---------------------------------
  157. begin 644 glcomp.exe
  158. M35HN``@``P`%`$(&>P87!X``````````/````"`@("`@("`@("`@("`@("`@>
  159. M("`@("`@("`@("`@("`:`0````L`#0`-`!````````````"ZR@`NB1:9`;0PF
  160. M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+7@31XX&/L@```ELK^Y=?7HOE7<-5B^RT/XM>!(M."(M6N
  223. M!LTA<@+K!%#H*?U=PU6+[(M>!-'C]X>R```(=!.X`@!0,\`STE!2_W8$Z$3]5
  224. M@\0(M$"+7@2+3@B+5@;-(7(/4(M>!-'C@8^R```06.L$4.CB_%W#``"/!CX!W
  225. MCP9``8\&0@$NC!YQ"XDV1`&)/D8!_(X&&`"^@``RY":L0(S%A]:3BS82`$9&1
  226. MN0$`@#X:``-R$8X&%`"+_K%_,L#RKN-N@/%_4(O!`\-`)?[_B_PK^')<B^<&C
  227. M'Q8'44GSI#+`JH[=A_*'V8O#B]!#Z!D`=P=R0.@2`'?Y/"!T"#P-=`0\"77H!
  228. M,L#KY`O`=`="J@K`=0%#AN`RP/GC%:Q)+")T#P0B/%QU!X`\(G4"K$D+]L/IY
  229. M5_59`\HNCAYQ"XD>.@%#`]N+](OL*^MRYHOEB2X\`>,.B78`@\4"-JP*P.#ZU
  230. M=/`SP(E&`"Z.'G$+BS9$`8L^1@'_-D(!_S9``:$Z`:,,`*$\`:,.`/\F/@$`E
  231. M````````````````$',+`````````````````````%!A;FEC+@T*````````[
  232. M`````````````````````,QDS&0`````````````````!`0`57-A9V4Z(&=L)
  233. M8V]M<"!X>'@N9VP@6VQI<W1F:6QE70H`0V]U;&1N)W0@9FEN9"``5&]O(&UA&
  234. M;GD@9FEL97,*`$-O=6QD;B=T(&]P96X@`%)E861I;F<Z"@!#:&]K:6YG+BXNW
  235. M("!.965D('-P86-E+BXN"@```'8&=@9V!@$@`B`"(`2@`J#_____________6
  236. M__________________________\`0/__````$P("!`4&"`@(%!4%$_\6!1$".
  237. M_________________P4%_____________________P__(P+_#_____\3__\"<
  238. >`@4/`O___Q/__________R/_____(_\3_P``````F
  239. ``
  240. end
  241. sum -r/size 17070/5111 section (from "begin" to "end")
  242. sum -r/size 23539/3630 entire input file
  243. ----------------- cut here ---------------------------------------------
  244. --
  245. Sincerely,                 berg%cip-s01.informatik.rwth-aachen.de@unido.bitnet
  246.            Stephen R. van den Berg.
  247. "I code it in 5 min, optimize it in 90 min, because it's so well optimized:
  248. it runs in only 5 min.  Actually, most of the time I optimize programs."
  249. received data 10603 bytes 128.68 secs
  250.  
  251.  
  252.